<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>K线训练营平台</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
        }
        .navbar {
            background-color: #333;
            overflow: hidden;
            padding: 10px 20px;
        }
        .navbar a {
            float: left;
            color: white;
            text-align: center;
            padding: 12px 16px;
            text-decoration: none;
            font-size: 17px;
        }
        .navbar a:hover {
            background-color: #ddd;
            color: black;
        }
        .user-info {
            float: right;
            color: white;
            padding: 12px 16px;
        }
        .content {
            padding: 20px;
        }
        h1 {
            color: #333;
        }
    </style>
</head>
<body>
    <div class="navbar">
        <a href="/">首页</a>
        <a href="#">K线练习</a>
        <a href="#">数据管理</a>
        <div class="user-info">
            {% if 'username' in session %}
                欢迎, {{ session['username'] }} | <a href="/logout" style="color: white;">退出</a>
            {% else %}
                <a href="/login" style="color: white;">登录</a> | <a href="/register" style="color: white;">注册</a>
            {% endif %}
        </div>
    </div>
    
    <div class="content">
        <h1>K线训练营平台</h1>
        {{ plot_div|safe }}
    </div>
    
    <div class="time-period-selector">
        <select id="timePeriod">
            <option value="1d">1天</option>
            <option value="1w">1周</option>
            <option value="1m">1月</option>
        </select>
        <button id="applyPeriod">应用</button>
    </div>
    
    <script>
        // 时间周期切换逻辑
        document.getElementById('applyPeriod').addEventListener('click', () => {
            const period = document.getElementById('timePeriod').value;
            fetch(`/api/chart?period=${period}`)
                .then(response => response.json())
                .then(updateChart);
        });
    </script>
</body>
</html>